<template>
	<view class="sign-in">

		<!-- <u-navbar title="我的积分" @rightClick="rightClick" :autoBack="true" bgColor="rgba(0,0,0,0)" leftIconColor="#ffffff"
			titleStyle="color:#ffffff;"> -->
			<!-- #ifdef APP-PLUS||H5 -->
			<!-- <view class="u-nav-slot" slot="right">
				<u-icon name="@appstatic/my/my_icon_question_white.png" size='24px' color="#ffffff"></u-icon>
			</view> -->
			<!-- #endif -->
		<!-- </u-navbar> -->
		
		<titlebara mode="" :backToIndex="false" :back="true" text="我的积分" backgroundColor='rgba(0,0,0,0)'
			color='#ffffff'  @rightIconClick='rightClick' img="@appstatic/my/my_icon_question_white.png">
		</titlebara>
		<z-paging ref="paging" v-model="dataList" @query="getUserScoreChangePageList" :fixed='false'
			:height='(windowHeight)+"px"'>
			<view slot="top">

				<view class="top-box" style="margin-bottom: 32rpx;">
					<image class="top-bg" src="@appstatic/my/orderHome/my_chest_image.png" mode="widthFix" />
					<view class="text-box">
						<view class="text">可用积分</view>
						<view class="num">{{score}}</view>
					</view>
				</view>
			</view>

			<view v-for="(item,index) in dataList" :key="index">
				<view class="item">
					<view class="item_row">
						<view class="item_row_text_title">{{item.changeAction}}</view>
						<view class="item_row_text_1" v-if="item.changeType=='增加'">{{item.changeScore}} 积分</view>
						<view class="item_row_text_2" v-else-if="item.changeType=='失效'">{{item.changeScore}} 积分</view>
						<view class="item_row_text_3" v-else>{{item.changeScore}} 积分</view>
					</view>
					<view class="item_row_text_time">{{item.changeTime}}</view>
				</view>

			</view>
		</z-paging>







	</view>
</template>

<script>
	const app = getApp();
	const network = require("@manager/network-manager.js")
	const dialog = require("../../../utils/dialog.js")
	import titlebara from '@/components/titlebar/titlebar'
	export default {
		components: {
			titlebara
		},
		data() {
			return {
				windowHeight:app.globalData.windowHeight,
				score: 0,
				dataList: [{
						title: '签到'
					},
					{
						title: '完成首次试驾'
					},
					{
						title: '老用户邀请新用户完成首次试驾奖励'
					},
					{
						title: '老用户邀请新用户完成首次试驾奖励,后台自定义积分描述超长文字展示这是二十字'
					}
				]

			};
		},
		onLoad: function(options) {

		},
		onShow() {
			// this.getUserScoreAccount()
			this.$nextTick(function() {
				this.$refs.paging.reload();
			})
		},



		mounted() {},
		methods: {
			//跳转积分声明
			rightClick: function() {
				uni.navigateTo({
					url: '/module_my/pages/myPoints/pointsInstructions?from=myPoints'
				})
			},
			//查询用户积分账户
			getUserScoreAccount: function() {
				var that = this;
				var uri = app.globalData.config.interfaces
					.URL_ACTIVITY_USERSCORE_GETUSERSCOREACCOUNT; ///levc-sys/sendMessage/updateLevcMessageUserReady
				var params = {
					userid: app.getUserId()
				};
				network.get(uri, params, 'form').then(res => {
					if (res.code == 200) {
						if (res.data.score) {
							that.score = res.data.score
						}
					} else {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})
					}

				}).catch(res => {
					uni.showToast({
						title: res.errMsg,
						duration: 3000,
						icon: 'none'
					})
					console.error(res);
				});
			},

			//查询用户积分流水
			getUserScoreChangePageList: function(pageNo, pageSize) {
				var that = this;
				var uri = app.globalData.config.interfaces
					.URL_ACTIVITY_USERSCORE_GETUSERSCORECHANGEPAGELIST;
				var params = {
					"pageNum": pageNo,
					"pageSize": pageSize,
					"userId": app.getUserId()
				};
				network.get(uri, params, 'form').then(res => {
					if (res.code == 200) {
						that.dataList = res.data.list;
						this.getUserScoreAccount()
						that.$refs.paging.complete(that.dataList);
					} else {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})
					}
				})
			},

		}


	}
</script>

<style lang='scss' scoped>
	.sign-in {
		width: 100vw;
		min-height: 100vh;
		box-sizing: border-box;
		background: #EDEDED url(@appstatic/img/my/bg-img.jpg) no-repeat;
		background-position: 0 0;
		background-size: 100%;
		background-attachment: fixed;

		image {
			image-rendering: -moz-crisp-edges;
			image-rendering: -o-crisp-edges;
			image-rendering: -webkit-optimize-contrast;
			image-rendering: crisp-edges;
			-ms-interpolation-mode: nearest-neighbor;
		}

		.top-box {
			width: 100%;
			height: 380rpx;
			overflow: hidden;
			position: relative;
			background: linear-gradient(180deg, #E44204 53.7%, #E03602 82.54%, #DD2E00 100%);

			.top-bg {
				width: 216rpx;
				height: 156rpx;
				position: absolute;
				bottom: 0;
				right: 20px;
			}

			.btn-img {
				width: 178rpx;
				z-index: 99;
				position: absolute;
				top: 240rpx;
				left: 56rpx;
			}

			.text-box {
				z-index: 99;
				position: absolute;
				bottom: 40rpx;
				left: 60rpx;
				color: #fff;
				display: flex;
				align-items: baseline;

				.num {
					font-weight: 700;
					font-size: 64rpx;
					line-height: 74rpx;
					margin-left: 32rpx;
				}

				.text {
					font-weight: 400;
					font-size: 32rpx;
					line-height: 46rpx;
					display: flex;
					align-items: center;
					text-align: center;
					color: #FFFFFF;

				}
			}
		}

		.item {
			width: 750rpx;
			display: flex;
			flex-direction: column;
			padding: 16rpx 32rpx;

			.item_row {
				display: flex;
				flex-direction: row;
				width: 686rpx;
				justify-content: space-between;
				align-items: flex-start;

				.item_row_text_title {
					width: 400rpx;
					font-style: normal;
					font-weight: 400;
					font-size: 32rpx;
					line-height: 46rpx;
					display: flex;
					align-items: center;
					color: #3D3A3A;
				}

				.item_row_text_1 {
					font-style: normal;
					font-weight: 400;
					font-size: 32rpx;
					line-height: 46rpx;
					display: flex;
					align-items: center;
					color: #EA5404;
				}

				.item_row_text_2 {
					font-style: normal;
					font-weight: 400;
					font-size: 32rpx;
					line-height: 46rpx;
					display: flex;
					align-items: center;
					color: #ADB0AE;
				}
				.item_row_text_3 {
					font-style: normal;
					font-weight: 400;
					font-size: 32rpx;
					line-height: 46rpx;
					display: flex;
					align-items: center;
					color: #3D3A3A;
				}
			}

			.item_row_text_time {
				font-style: normal;
				font-weight: 400;
				font-size: 28rpx;
				line-height: 32rpx;
				display: flex;
				align-items: center;
				color: #ADB0AE;
				margin-top: 8rpx;
			}


		}
	}
</style>
